package com.hjw.weixun.action.oauth;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import weibo4j.http.RequestToken;
import weibo4j.oauth.WebOAuth;

import com.hjw.weixun.action.GenericAction;
import com.hjw.weixun.domain.Weixun;

public class SinaOauthAction extends GenericAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	private static final Logger logger = LoggerFactory
			.getLogger(SinaOauthAction.class);

	private String path;

	private Weixun weixun;

	public String getOauth() {

		if (null == weixun || path == weixun.getPath()) {
			return null;
		}

		String callBackPath = super.getBasePath() + weixun.getPath() + "/msg";
		RequestToken resToken = WebOAuth.request(callBackPath);

		path = resToken.getAuthenticationURL();
		super.getRequest().getSession().setAttribute("resToken", resToken);

		return SUCCESS;
	}

	public String getPath() {
		return path;
	}

	public void setPath(String path) {
		this.path = path;
	}

	public Weixun getWeixun() {
		return weixun;
	}

	public void setWeixun(Weixun weixun) {
		this.weixun = weixun;
	}

}
